import vueRouter from 'vue-router'
import Vue from 'vue'

//获取原型对象上的push函数
const originalPush = vueRouter.prototype.push
//修改原型对象中的push方法
vueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

Vue.use(vueRouter)

let router = new vueRouter({
  routes: [
    {
      path: '/svg',
      name: 'svg',
      component: () => import('./views/Svg')
    },
    {
      path: '/module',
      name: 'module',
      component: () => import('./views/Module')
    },
    {
      path: '/render',
      name: 'render',
      component: () => import('./views/render')
    },
    {
      name: 'double-bind',
      path: '/double-bind',
      component: () => import('./views/double-bind.vue')
    },
    {
      name: 'slot',
      path: '/slot',
      component: () => import('./views/slot')
    },
    {
      name: 'lifeLoop',
      path: '/lifeLoop',
      component: () => import('./views/lifeLoop')
    },
    {
      name: 'functional',
      path: '/functional',
      component: () => import('./views/functional')
    },
    {
      name: 'focus',
      path: '/focus',
      component: () => import('./views/directive')
    },
    {
      name: 'provide',
      path: '/provide',
      component: () => import('./views/provide')
    },
    {
      path: '/form',
      name: 'form',
      component: () => import('./views/CForm')
    },
    {
      path: '/demo',
      name: 'demo',
      component: () => import('./views/Dome')
    },
    {
      path: '/CSS',
      name: 'CSS',
      component: () => import('./views/CSS'),
      children: [
        {
          path: 'flex',
          name: 'flex',
          component: () => import('./views/CSS/flex')
        }
      ]
    }
  ]
})

export default router
